package club.justwill.single.assembler;

import club.justwill.single.bean.UserAddressResp;
import club.justwill.single.persistence.document.UserAddress;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by xiangnan on 16-1-16.
 */
@Component
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
public class UserAddressAssemble {
    public UserAddressResp assemble(UserAddress userAddress) {
        return new UserAddressResp(userAddress);
    }

    public List<UserAddressResp> assembleAddressList(List<UserAddress> userAddressList) {
        List<UserAddressResp> userAddressRespList = new ArrayList<UserAddressResp>();
        for(UserAddress userAddress : userAddressList) {
            userAddressRespList.add(assemble(userAddress));
        }
        return userAddressRespList;
    }
}
